/**
 * @Author: 陈瑞鹏
 * @Date:   2022-10-17 09:31:30
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-10-17 09:42:08
 */
import mongoose from 'mongoose';

const Schema = mongoose.Schema;
const RequestLogsSchema: mongoose.Schema = new Schema({
  openId: { type: String, display: '用户id', index: true },
  originalUrl: { type: String, display: '访问路由', index: true },
  referer: { type: String, display: '来路' },
  method: { type: String, display: '请求方式' },
  statusCode: { type: Number, display: '状态码' },
  ip: { type: String, display: '请求ip', index: true },
  parameter: { type: Schema.Types.Mixed, display: '请求参数' },
  handleTime: { type: Number, display: '处理时间(ms)' },
  pmId: { type: String, display: '唯一标识码' },
  mem: { type: Object, display: '内存' },
  requestTime: { type: String, display: '请求时间' },
  responeseTime: { type: Number, display: '响应时间' },
  createTime: { type: String, display: '创建时间' },
  createTtl: { type: String, display: '创建时间戳', index: true }
}).index({ openId: 1, originalUrl: 1 }).index({ openId: 1, method: 1 }).index({ pmId: 1 });

const RequestLogs = mongoose.model('RequestLogs', RequestLogsSchema);
export default RequestLogs;